﻿@inject NavigationManager NavigationManager
@inject IDataCacheService _dataCacheService


<div style=" display: flex; flex-direction: column; align-items: flex-start;">
    @foreach (var item in Model)
    {
        <CnGalWebSite.Components.Buttons.MasaButton TextStyle Text="@($"{new String(' ', Level)}{item.Text}")" OnClick="()=>OnActiveUpdate(item)" Color="@(item.IsActive?_dataCacheService.ThemeSetting.ThemeColor:"grey")" />
        @if (item.Nodes != null && item.Nodes.Any())
        {
            <MasaCatalogItem Model="item.Nodes" Level="Level+1"  Url="@Url"/>
        }

    }

</div>

@code {
    [Parameter]
    public List<ArticleCatalogModel> Model { get; set; }
    [Parameter]
    public int Level { get; set; }
    [Parameter]
    public string Url { get; set; }

    public void OnActiveUpdate(ArticleCatalogModel model)
    {
        model.IsActive = true;
        NavigationManager.NavigateTo( $"{Url}#{model.Href}");

    }
}
